-
Notifications
You must be signed in to change notification settings - Fork 17
add: github actions to lint and npm audit #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe GitHub Actions workflow for linting and auditing was refactored from referencing an external reusable workflow to an inline job definition. The workflow is now configured to trigger on pushes and pull requests to main, master, and develop branches, with pull request runs further filtered to only execute when relevant JavaScript/TypeScript or package files are changed. The workflow steps include repository checkout, Node.js setup, dependency installation, and conditional execution of ESLint and npm audit steps based on the types of files changed. Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub Actions
participant Repo
participant Node.js
participant npm
participant ESLint
GitHub Actions->>Repo: Checkout repository (full history)
GitHub Actions->>Node.js: Setup Node.js 16 (with npm cache)
GitHub Actions->>npm: Install dependencies (npm ci)
GitHub Actions->>Repo: Detect changed files (JS/TS/package files)
alt JS/TS files changed
GitHub Actions->>ESLint: Run ESLint on changed files
end
alt package.json or package-lock.json changed
GitHub Actions->>npm: Run npm audit
end
Possibly related PRs
Suggested reviewers
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
β»οΈ Duplicate comments (1)
.github/workflows/lint_audit.yml (1)
48-50: Duplicate: Audit condition depends on updated changed-files config
As noted above, the npm audit stepβsifdepends onall_changed_filescontaining package files. Once you update the patterns, this condition will work as intended.
π§Ή Nitpick comments (1)
.github/workflows/lint_audit.yml (1)
30-32: Remove trailing whitespace
The blank line at line 32 contains trailing spaces; trimming it will satisfy YAML lint rules.π§° Tools
πͺ YAMLlint (1.35.1)
[error] 32-32: trailing spaces
(trailing-spaces)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
.github/workflows/lint_audit.yml(1 hunks)
π§° Additional context used
πͺ actionlint (1.7.4)
.github/workflows/lint_audit.yml
20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
25-25: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
πͺ YAMLlint (1.35.1)
.github/workflows/lint_audit.yml
[error] 32-32: trailing spaces
(trailing-spaces)
π Additional comments (4)
.github/workflows/lint_audit.yml (4)
8-14: Pull request triggers scoped to relevant file changes
Filteringpull_requestevents to JS/TS and package files will prevent unnecessary CI runs on unrelated commits.
18-23: Full repository checkout for accurate diff detection
Usingfetch-depth: 0onactions/checkout@v3is required fortj-actions/changed-filesto compute the full diff correctly. Perfect.π§° Tools
πͺ actionlint (1.7.4)
20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
24-28: Node.js setup with caching is optimal
actions/setup-node@v3withcache: 'npm'and pinnednode-version: '16.x'ensures fast, repeatable installs.π§° Tools
πͺ actionlint (1.7.4)
25-25: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
43-47: Conditional ESLint run on changed files
Running ESLint only whenany_changed == 'true'is efficient and prevents full runs on unrelated commits.
| - name: Get changed files | ||
| id: changed-files | ||
| uses: tj-actions/changed-files@v35 | ||
| with: | ||
| files: | | ||
| **/*.js | ||
| **/*.ts | ||
| **/*.tsx | ||
| **/*.jsx | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Include dependency files in changed-files patterns
Right now the changed-files action only watches JS/TS source, so changes to package.json or package-lock.json wonβt be reported. This breaks your npm audit condition.
Apply this diff to capture dependency file changes:
with:
files: |
**/*.js
**/*.ts
**/*.tsx
**/*.jsx
+ package.json
+ package-lock.jsonπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v35 | |
| with: | |
| files: | | |
| **/*.js | |
| **/*.ts | |
| **/*.tsx | |
| **/*.jsx | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v35 | |
| with: | |
| files: | | |
| **/*.js | |
| **/*.ts | |
| **/*.tsx | |
| **/*.jsx | |
| package.json | |
| package-lock.json |



π Description
Implements PSMRI/AMRIT#3
Enable eslint and npm audit via github actions for the repository
β Type of Change
Summary by CodeRabbit